/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import CRUD.ForumHome;
import beans.AddModBean;
import beans.PermToForum;
import java.util.List;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import xmlMapping.Forum;

/**
 *
 * @author ABDELMOHSEN
 */
public class GetAllForums extends org.apache.struts.action.Action {
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        AddModBean bean=(AddModBean)form;
        List<Forum> f=(new ForumHome()).getAllForums();
        Vector<PermToForum> forums=new Vector<PermToForum>();
        for(int i=0;i<f.size();i++){
            forums.add(new PermToForum(f.get(i).getName(), f.get(i).getForumId()));
        }
        bean.setForums(forums);
        return mapping.findForward("next");
    }
}
